package com.jic.market.impl;

import com.alibaba.excel.metadata.BaseRowModel;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.market.entity.PatchGrouponMp;
import com.jic.market.impl.excel.ExcelUtil;
import com.jic.market.mapper.PatchGrouponMpMapper;
import com.jic.market.service.PatchGrouponMpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 商家商品活动库存限制表
 * @author : yinhaijun
 * @email : 
 * @since : 2020-01-10 11:00:34
 * @version : v1.0.0
 */
@Slf4j
@Service
public class PatchGrouponMpServiceImpl implements PatchGrouponMpService {

    @Autowired
    private PatchGrouponMpMapper patchGrouponMpMapper;

    @Override
    public long insert(PatchGrouponMp patchGrouponMp) {
        long flag = patchGrouponMpMapper.insert(patchGrouponMp);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return patchGrouponMpMapper.delete(id);
    }

    @Override
    public long update(PatchGrouponMp record, PatchGrouponMp example) {
        return patchGrouponMpMapper.update(record, example);
    }

    @Override
    public PatchGrouponMp queryByPrimaryKey(Long id){
        return patchGrouponMpMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<PatchGrouponMp> query(PatchGrouponMp patchGrouponMp){
        return patchGrouponMpMapper.query(patchGrouponMp);
    }

    @Override
    public PageResult<PatchGrouponMp> queryPage(PatchGrouponMp patchGrouponMp, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<PatchGrouponMp> list = patchGrouponMpMapper.queryPage(startIndex, pageQuery.getLimit(), patchGrouponMp);
        long count = patchGrouponMpMapper.queryPageCount(patchGrouponMp);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }

    @Override
    public long insertBatch(List<PatchGrouponMp> list) {
        return patchGrouponMpMapper.insertBatch(list);
    }

}